package com.hxkj.controller.userCenter;

import com.hxkj.domain.po.DefaultAvatar;
import com.hxkj.service.userCenter.DefaultAvatarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.Callable;

@RestController
@RequestMapping(value = "/defaultAvatar")
public class DefaultAvatarController {
    @Autowired
    private DefaultAvatarService defaultAvatarService;

    @RequestMapping(value = "/getList")
    public Callable<List<DefaultAvatar>> getList() throws Exception {
        return () -> defaultAvatarService.getList();
    }

    @RequestMapping(value = "/save")
    public void save(@ModelAttribute DefaultAvatar defaultAvatar) throws Exception {
        defaultAvatarService.save(defaultAvatar);
    }

    @RequestMapping(value = "/delete")
    public void delete(@ModelAttribute DefaultAvatar defaultAvatar) throws Exception {
        defaultAvatarService.delete(defaultAvatar);
    }

    @RequestMapping(value = "/getRandomInfo")
    public Callable<DefaultAvatar> getRandomInfo() throws Exception{
        return () -> defaultAvatarService.getRandomInfo();
    }
}
